<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        :root {
            --line-border-fill: #3498db;
            --line-border-empty: #e0e0e0;
        }
        * {
            box-sizing: border-box;
        }
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
            margin: 0;
            background-color: #f6f7fb;
        }
        .contaniner {
            text-align: center;
        }
        .porgress_container {
            display: flex;
            justify-content: space-between;
            position: relative;
            width: 350px;
            max-width: 100%;
            margin-bottom: 30px;
       } 
        .porgress_container::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            z-index: -1;
            transform: translateY(-50%);
            height: 4px;
            width: 100%;
            background-color: var(--line-border-empty);
        }
        .porgress {
            position: absolute;
            top: 50%;
            left: 0;
            z-index: -1;
            transform: translateY(-50%);
            transition: all 0.4s ease;
            height: 4px;
            width: 0%;
            background-color: var(--line-border-fill);
        }
        .circle {
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #fff;
            color: #999;
            border-radius: 50%;
            border: 3px solid var(--line-border-empty);
            transition: all 0.4s ease;
            height: 30px;
            width: 30px;
        }
        .circle.active {
            border-color: var(--line-border-fill);
        }
        .btn.active {
            transform: scale(0.98);
        }
        .btn:focus {
            outline: 0;
        }
        .btn:disabled {
            background-color: var(--line-border-empty );
            cursor: not-allowed;
        } 
    </style>
</head>
<body>
    <div class="contaniner">
        <div class="porgress_container">
            <div class="porgress"></div>
            <div class="circle active">1</div>
            <div class="circle">2</div>
            <div class="circle">3</div>
            <div class="circle">4</div>
        </div>
        <button class="btn" id="prev" disabled>上一个</button>
        <button class="btn" id="next">下一个</button>
    </div>

    <script>
        let porgress = document.getElementsByClassName("porgress")[0];
        let prev = document.getElementById("prev");
        let next = document.getElementById("next");
        let circles = document.querySelectorAll(".circle");

        let currentActive = 1;

        next.addEventListener("click", () => {
            currentActive++;
            if (currentActive > circles.length) {
                currentActive = circles.length;
            };
            update();
        });
        prev.addEventListener("click", () => {
            currentActive--;
            if (currentActive < 1) {
                currentActive = 1;
            };
            update();
        });
        function update() {
            circles.forEach((circle, index) => {
                if (index < currentActive) {
                    circle.classList.add("active");
                } else {
                    circle.classList.remove("active");
                };
            });
            let actives = document.querySelectorAll(".active");
            porgress.style.width = (actives.length - 1) / (circles.length - 1) * 100 + "%";
            if (currentActive === 1) {
                prev.disabled = true;

            }else if (currentActive === circles.length) {
                next.disabled = true;
                
            }else{
                prev.disabled = false;
                next.disabled = false;
            };
        };
    </script>
</body>
</html>